﻿using System;
using System.Linq;

namespace Cartoons.Books.Model
{
    public class ScalarTextPropertyFilter : BookFilter
    {
        private string text;
        public ScalarTextPropertyFilter(string propertyName, string text) : base(propertyName)
        {
            this.text = text;
        }
        
        protected override bool IsMatch(Book book)
        {
            return typeof(Book).GetProperty(propertyName).GetValue(book, null).ToString().ToLower().StartsWith(text.ToLower());
        }
    }
}
